<?php
//--------------------------------------------------------------------------------------
// FlatNuke - Flat Text Based Content Management System
// ====================================================
//
// Copyright (c) 2003-2004 by Simone Vellei
// http://flatnuke.sourceforge.net
// Files - the FlatNuke file manager
// Section  by vroby (http://www.sdlbasic.altervista.org - __vroby__@libero.it)
// Graphics, testing and restyling by Danix (http://www.wipenpack.com  - winpenpack@gmail.com)
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//____________________________________________________________________________________________________________________________________

structure_openBlock("table appl",apptitle($appname),"");

//la directory dei submit
global $updatefiles;
$updatefiles="applications/".appname()."/none_updatefiles";

// la dimensione massima di un file
$maxFileSize=20000000;

// scarica le variabili che servono
$dpath=$_GET['dpath'];
$action=$_GET['action'];
$appname =$_GET['appname'];


//caricamento condizionale del "pesante" modulo ziplib
/*
if ($action=="zip_dir"){
	chdir("../../");
	include "ziplib.php";
	zip_dir($dpath);
	die();
}
*/

//include"config.php";
//fissa $siteurl se non finisce con /
if (substr($siteurl,-1)!="/")$siteurl=$siteurl."/";

//carica la lingua se esiste
if (file_exists("applications/$appname/none_lang/$lang.inc"))
    include "applications/$appname/none_lang/$lang.inc";
else
    include "applications/$appname/none_lang/it.inc";

//style.css
echo "<link rel=\"StyleSheet\" href=\"applications/$appname/style.css\" type=\"text/css\">";


//startUP
//------------------------

// se la directory datas/applications/$appname non c'e' la crea:
if(file_exists("datas/applications/".sec_title($appname))==false){
    //baco segnalato da Simone uso 0775 per essere sicuro dei permessi
    mkdir("datas/applications/".sec_title($appname),0775);
}

//__________________________________________________________________________________________________________________________________

// tocca tutte le cartelle del path per aggiornarne la data
function touch_path($path){
    $cpath=$path;
    while ($cpath !=''){
	$cpath=dirname($cpath);
	if (!@touch($cpath)) return 0;
    }
}

//__________________________________________________________________________________________________________________________________

//restituisce il titolo della sezione (senza xx_ o none_)
function sec_title($appname){
    if ($appname[2]=="_")return substr($appname,3);
    if ($appname[4]=="_")return substr($appname,5);
    return $appname;
}
//__________________________________________________________________________________________________________________________________

//carica in  un array l'elenco dei file di una directory
function listdir($path){
    $hdir=opendir($path);
    while (false !== ($f= readdir($hdir)))
	$filename[$i++] =$f;
    closedir($hdir);
    if (count($filename))sort($filename);
    return $filename;
}
//__________________________________________________________________________________________________________________________________

//legge la descrizione di un file/dir
function readdesc($f){
    if (file_exists($f)){
	$hf=fopen("$f","r");
	$desc=fread($hf,4096);
	fclose($hf);
    }
    else{
	$desc="";
    }
    return $desc;
}
//__________________________________________________________________________________________________________________________________

//scrive la descrizione di un file/dir
function writedesc($f,$desc){
	$hf=fopen("$f","w");
	fwrite($hf,$desc);
	fclose($hf);
}
//__________________________________________________________________________________________________________________________________


//lista i file del percorso in un array
/*function listfile($dpath,$path){
    global $list;
    $files_added=0;
    addlist($dpath,$path,$files_added);
    return $list;
}*/

//handler ricorsivo della catalogazione files
/*
function addlist($dpath,$path,$files_added){
    global $list;

    $hdir=opendir($dpath.$path);
    while (false !== ($f= readdir($hdir)))
	$files[$n++] =$f;
    closedir($hdir);
    if ($n>0){
	foreach ($files as $filename){
	    if ($filename[0]!="." && substr($dpath.$filename,-6)!=".count" && substr($dpath.$filename,-12)!=".description"){
		if (is_file($dpath.$path.$filename)==true){
		    //incrementa il downloadcount dei file scaricati nella directory
		    $f=$dpath.$path.$filename.".count";
		    if(file_exists("$f")==false){
			$hf=fopen("$f","w");
			fwrite($hf,"1");
			fclose($hf);
		    }else{
			$hf=fopen("$f","r");
			$i=fread($hf,1024);
			$i++;
			fclose($hf);
			$hf=fopen("$f","w");
			fwrite($hf,$i);
			fclose($hf);
		    }
		    $list[$files_added++]=$path.$filename;
		}else{
		    //ricorsione!!!
		    $list[$files_added++]=$path.$filename;
		    addlist($dpath,$path.$filename."/",$files_added);
		}
	    }
	}
    }
}
*/
//__________________________________________________________________________________________________________________________________

// comprime una cartella in un file da scaricare al volo
function zip_dir($dpath){
    $siteurl=$_GLOBALS['siteurl'];
    $appname =$_GET['appname'];
    $filename =$_GET['filename'];

    $path=$filename."/";
    $list=listfile($dpath,$path);

    $zipfile = new zipWriter("zipfolder",$filename.".zip");
    foreach($list as $filename){
	if ($filename[0]!="."){
	    if (is_dir($dpath.$filename)){
		$zipfile ->addDir($filename);
	    }
	    else{
		$filedata = file_get_contents($dpath.$filename);
		$zipfile ->addRegularFile($filename,$filedata);
	    }
	}
    }
    $zipfile ->finish();
}
//__________________________________________________________________________________________________________________________________

// visualizza la classifica dei piu' nuovi
function top_new($dpath){
    global $list;
    $siteurl=$_GLOBALS['siteurl'];
    $appname =$_GET['appname'];


    $extfs=opendir("applications/$appname/none_images");
    while (false !== ($extimg= readdir($extfs))){
	if (substr($extimg,-4)==".png")
	    $ext[substr(substr($extimg,0,-4),-3)]=$extimg;
    }
    closedir($extfs);

    top_new_handler("datas/applications/".sec_title($appname)."/");
    if(count($list)>0){
	arsort($list,SORT_NUMERIC);
	$oldfilehit="";
	$entry=0;

	echo "<br>";
	foreach($list as $filehit){
	    if ($filehit!=$oldfilehit){
		$oldfilehit=$filehit;
		$filehitlev =array_keys ($list,$filehit);
		foreach($filehitlev as $filename){
		    $entry++;
		    if ($entry>20)break;
		    $f=$filename.".count";
		    if (file_exists($f)){
			$hf=fopen("$f","r");
			$count=fread($hf,1024);
			fclose($hf);
		    }
		    else{
			$count=0;
		    }
		    $actionlink="index.php?appname=".$appname."&dpath=".$filename;

		    if ($ext[substr($filename,-3)]!="")
			$picture="<img src='applications/$appname/none_images/".$ext[substr($filename,-3)]."' border='0'>";
		    else
			$picture="<img src='applications/$appname/none_images/unknown.png' border='0'>";
		    if (substr($filename,-2)=="gz")
			$picture="<img src='applications/$appname/none_images/tgz.png' border='0'>";
		 // Visualizza Top new
		    echo "<div class='new_file'>";
			echo "<table border='0'><tr>";
		    echo "<td  valign='top' align='right' width='3%'>";
		    echo "$picture";
		    echo "</td>";
		    echo "<td align='justify' valign=top>";
			echo "$entry - <a href='$actionlink&action=download'><font class='red_bold'>".basename($filename)."</font></a>";
			echo"<font class='black'> - "._RILASCIO." </font> ".date("j.m.y",filemtime("$filename"))."";

			if(strtolower(substr($filename,-4))<>".lnk"){
			echo "<font class='black'> - "._SIZE_FILE." </font>".round(filesize("$filename")/1000)."Kb ";
			}
			else
			echo "<font class='black'> - "._FILE_REMOTO." </font>";

		    echo"<font class='black'> - Downloads: </font> $count ";
		    $dpath1=$filename;
			if(file_exists("$dpath1.updateby.description")){
				if(filesize("$dpath1.updateby.description")>1){
				echo "<br><font class='black'>"._UPDATEBY." </font>";
				$updateby=trim(join(file("$dpath1.updateby.description")));
				echo"<a href='forum/index.php?op=profile&amp;user=$updateby'>$updateby</a>";
				}
			}

			if(file_exists("$dpath1.version.description")){
				if(filesize("$dpath1.version.description")>1){
				echo "<font class='black'> - "._VERSION." </font>";
				readfile("$dpath1.version.description");
				}
			}
			echo "<br>";
			if(file_exists("$dpath1.description")){
				if(filesize("$dpath1.description")>1){
				echo "<font class='grey_bold'>"._DESCRIPTION." </font>";
				readfile("$dpath1.description");
				}
			}
			echo "</td>";
		    echo "<td align='right' valign=top >";
		    if ( filemtime("$filename")> mktime (0,0,0,date("m"),date("d")-5,  date("Y")))
			echo"<img src='applications/$appname/none_images/new.gif'>";
		    echo "</td></tr>";
            echo "</table></div>";
		}
		if ($entry>=20)break;
	    }
	    if ($entry>=20)break;
	}

    }
	echo "<br><div align='left'><img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'><font class='black'>[Main]</font></a>&nbsp;&nbsp;";
    echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";
}

//l'handler di ricerca(la funzione e' ricorsiva)
function top_new_handler($dpath){
    global $list;
    $siteurl=$_GLOBALS['siteurl'];
    $appname =$_GET['appname'];
    foreach(listdir($dpath.$path) as $filename){
	if ($filename[0]!="."){
	    if (substr($dpath.$filename,-6)!=".count" && substr_count($dpath.$filename,".description")==0 && !is_dir($dpath.$filename)){
		$f=$dpath.$filename;
		if (file_exists($f)){
		    $count=filemtime($f);
		}
		else{
		    $count=0;
		}

		$list[$dpath.$filename]=$count;
	    }
	    //ricorsione!!!
	    if (is_dir($dpath.$filename))top_new_handler($dpath.$filename."/",$pattern);
	}
    }
}

//__________________________________________________________________________________________________________________________________

// visualizza la classifica dei files piu' scaricati
function top_download($dpath){
    global $list;
    $siteurl=$_GLOBALS['siteurl'];
    $appname =$_GET['appname'];


    $extfs=opendir("applications/$appname/none_images");
    while (false !== ($extimg= readdir($extfs))){
	if (substr($extimg,-4)==".png")
	    $ext[substr(substr($extimg,0,-4),-3)]=$extimg;
    }
    closedir($extfs);

    top_download_handler("datas/applications/".sec_title($appname)."/");
    if(count($list)>0){
	arsort($list,SORT_NUMERIC);
	$oldfilehit="";
	$entry=0;
	echo "<br>";
	foreach($list as $filehit){
	    if ($filehit!=$oldfilehit){
		$oldfilehit=$filehit;
		$filehitlev =array_keys ($list,$filehit);
		foreach($filehitlev as $filename){
		    $entry++;
		    if ($entry>20)break;
		    $f=$filename.".count";
		    if (file_exists($f)){
			$hf=fopen("$f","r");
			$count=fread($hf,1024);
			fclose($hf);
		    }
		    else{
			$count=0;
		    }
		    $actionlink="index.php?appname=".$appname."&dpath=".$filename;

		    if ($ext[substr($filename,-3)]!="")
			$picture="<img src='applications/$appname/none_images/".$ext[substr($filename,-3)]."' border='0'>";
		    else
			$picture="<img src='applications/$appname/none_images/unknown.png' border='0'>";
		    if (substr($filename,-2)=="gz")
			$picture="<img src='applications/$appname/none_images/tgz.png' border='0'>";


		 // Visualizza Top downloads
		    echo "<div class='new_file'>";
			echo "<table border='0'><tr>";
		    echo "<td  valign='top' align='right' width='3%'>";
		    echo "$picture";
		    echo "</td>";
		    echo "<td align='justify' valign=top>";
			echo "$entry - <a href='$actionlink&action=download'><font class='red_bold'>".basename($filename)."</font></a>";
			echo"<font class='black'> - "._RILASCIO." </font> ".date("j.m.y",filemtime("$filename"))."";

			if(strtolower(substr($filename,-4))<>".lnk"){
			echo "<font class='black'> - "._SIZE_FILE." </font>".round(filesize("$filename")/1000)."Kb ";
			}
			else
			echo "<font class='black'> - "._FILE_REMOTO." </font>";
		    echo"<font class='black'> - Downloads: </font> $count ";
		    $dpath1=$filename;

			if(file_exists("$dpath1.updateby.description")){
				if(filesize("$dpath1.updateby.description")>1){
				echo "<br><font class='black'>"._UPDATEBY." </font>";
				$updateby=trim(join(file("$dpath1.updateby.description")));
				echo"<a href='forum/index.php?op=profile&amp;user=$updateby'>$updateby</a>";
				}
			}

			if(file_exists("$dpath1.version.description")){
				if(filesize("$dpath1.version.description")>1){
				echo "<font class='black'> - "._VERSION." </font>";
				readfile("$dpath1.version.description");
				}
			}
			echo "<br>";
			if(file_exists("$dpath1.description")){
				if(filesize("$dpath1.description")>1){
				echo "<font class='grey_bold'>"._DESCRIPTION." </font>";
				readfile("$dpath1.description");
				}
			}
			echo "</td>";
		    echo "<td align='right' valign=top >";
		    if ( filemtime("$filename")> mktime (0,0,0,date("m"),date("d")-5,  date("Y")))
			echo"<img src='applications/$appname/none_images/new.gif'>";
		    echo "</td></tr>";
            echo"</table></div>";
		}
	    if ($entry>=20)break;
	    }
	if ($entry>=20)break;
	}

    }
	echo "<br><div align='left'><img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'><font class='black'>[Main]</font></a>&nbsp;&nbsp;";
    echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";

}

// l'handler di ricerca(la funzione e' ricorsiva)
function top_download_handler($dpath){
    global $list;
    $siteurl=$_GLOBALS['siteurl'];
    $appname =$_GET['appname'];
    foreach(listdir($dpath.$path) as $filename){
	if ($filename[0]!="."){
	    if (substr($dpath.$filename,-6)!=".count" && substr_count($dpath.$filename,".description")==0 && !is_dir($dpath.$filename)){
		$f=$dpath.$filename.".count";
		if (file_exists($f)){
		    $hf=fopen("$f","r");
		    $count=fread($hf,1024);
		    fclose($hf);
		}
		else{
		    $count=0;
		}

		$list[$dpath.$filename]=$count;
	    }
	    //ricorsione!!!
	    if (is_dir($dpath.$filename))top_download_handler($dpath.$filename."/",$pattern);
	}
    }
}
//__________________________________________________________________________________________________________________________________

// visualizza la pagina di ricerca
function search($dpath){
	$siteurl=$_GLOBALS['siteurl'];
	$appname =$_GET['appname'];


  //Search
	echo "<br><div>";
    echo "<br><br><form name='addfile' enctype='multipart/form-data' action='".$siteurl."index.php?appname=$appname&dpath=$dpath&action=exec_search' method='post'>";
    echo "<input type='submit' class='input_search' value='"._FINDFILES."'/>";
	echo "&nbsp;<input class='input_text' type='text' name='file'/>";
    echo "</form>";
    echo "</div>";

	echo "<br><br><div align='left'><img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'><font class='black'>[Main]</font></a>&nbsp;&nbsp;";
    echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";
}
//__________________________________________________________________________________________________________________________________

// cerca il file
function exec_search($dpath){
    $siteurl=$_GLOBALS['siteurl'];
    $appname =$_GET['appname'];
    $pattern=$_POST['file'];


    echo "<br><left><div class='black_bold'><img src='applications/$appname/none_images/icon2.gif' border='0'> "._FINDINGFILES." <font class='black'>\"$pattern\"</font></div></left>";
    echo "<br>";
    $pattern=str_replace("*","",$pattern);
    $path="datas/applications/".sec_title($appname)."/";
    if ($pattern!="")
	searchdir($path,$pattern);
	echo "<br><div align='left'><img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'><font class='black'>[Main]</font></a>&nbsp;&nbsp;";
    echo "<img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=".$appname."&action=search'><font class='black'>["._NEW_SEARCH."]</font></a>&nbsp;&nbsp;";
	echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";
}

//l'handler di ricerca(la funzione e' ricorsiva)
function searchdir($dpath,$pattern){
    $siteurl=$_GLOBALS['siteurl'];
    $appname =$_GET['appname'];

    $extfs=opendir("applications/$appname/none_images");
    while (false !== ($extimg= readdir($extfs))){
	if (substr($extimg,-4)==".png")
	    $ext[substr(substr($extimg,0,-4),-3)]=$extimg;
    }
    closedir($extfs);

    foreach(listdir($dpath) as $filename){
	if ($filename[0]!="."){
	    if (strpos(strtolower($dpath.$filename),strtolower($pattern)) || strpos(strtolower(readdesc($dpath.$filename .".description")),strtolower($pattern)))
		if (substr($dpath.$filename,-6)!=".count" && substr_count($dpath.$filename,".description")==0  && !is_dir($dpath.$filename)){
		    $f=$dpath.$filename.".count";
		    if (file_exists($f)){
			$hf=fopen("$f","r");
			$count=fread($hf,1024);
			fclose($hf);
		    }
		    else{
			$count=0;
		    }

		    $actionlink="index.php?appname=".$appname."&dpath=$dpath&filename=$filename";
		    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
			$rename_file="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=rename_file'>"._REN."</a>]";
			$delete_file="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=delete_file'>"._DEL."</a>]";
			$cut_file="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=cut_file'>"._CUT."</a>]";

			}

		    if ($ext[substr($filename,-3)]!="")
			$picture="<img src='applications/$appname/none_images/".$ext[substr($filename,-3)]."' border='0'>";
		    else
			$picture="<img src='applications/$appname/none_images/unknown.png' border='0'>";
		    if (substr($filename,-2)=="gz")
			$picture="<img src='applications/$appname/none_images/tgz.png' border='0'>";

		 // Visualizza Files trovati
			echo "<table border='0' width='100%'><tr>";
			echo "<td valign='top'>";
			echo "<div class='file'>";
		    echo "<table border='0'><tr>";
		    echo "<td  valign='top' align='right' width='3%'>";
		    echo "$picture";
		    echo "</td>";
		    echo "<td align='justify' valign=top>";
            echo "<a href='$actionlink&action=download'><font class='red_bold'>$filename</font></a>";
			echo"<font class='black'> - "._RILASCIO." </font> ".date("j.m.y",filemtime("$dpath/$filename"))."";


			if(strtolower(substr($filename,-4))<>".lnk"){
			echo "<font class='black'> - "._SIZE_FILE." </font>".round(filesize("$dpath/$filename")/1000)."Kb ";
			}
			else
			echo "<font class='black'> - "._FILE_REMOTO." </font>";


		    echo"<font class='black'> - Downloads: </font> $count";
			$dpath1="$dpath/$filename";
			if(file_exists("$dpath1.updateby.description")){
				if(filesize("$dpath1.updateby.description")>1){
				echo "<br><font class='black'>"._UPDATEBY." </font>";
				$updateby=trim(join(file("$dpath1.updateby.description")));
				echo"<a href='forum/index.php?op=profile&amp;user=$updateby'>$updateby</a>";
				}
			}

			if(file_exists("$dpath1.version.description")){
				if(filesize("$dpath1.version.description")>1){
				echo "<font class='black'> - "._VERSION." </font>";
				readfile("$dpath1.version.description");
				}
			}
			echo "<br>";
		 // Admin mini panel
		    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
		    echo "<span class='admin_panel'>$cut_file $delete_file $rename_file</span>";
		    echo "<br>";
			}

			if(file_exists("$dpath1.description")){
				if(filesize("$dpath1.description")>1){
				echo "<font class='grey_bold'>"._DESCRIPTION." </font>";
				readfile("$dpath1.description");
				}
			}
			echo "</td>";
		    echo "<td align='right' valign=top >";
		    if ( filemtime("$dpath/$filename")> mktime (0,0,0,date("m"),date("d")-5,  date("Y")))
			echo"<img src='applications/$appname/none_images/new.gif'>";

			echo "</tr></table>";
			echo "</td></tr></table>";
		}
		//ricorsione!!!
		if (is_dir($dpath.$filename))searchdir($dpath.$filename."/",$pattern);
	    }
    }
}
//__________________________________________________________________________________________________________________________________

// visualizza l'help
function help($dpath){
	$siteurl=$_GLOBALS['siteurl'];
	$appname =$_GET['appname'];

 	echo ""._HELP_TXT."<br />";

	echo "<div align='left'><img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'><font class='black'>[Main]</font></a>&nbsp;&nbsp;";
    echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";
}
//__________________________________________________________________________________________________________________________________


// sposta il file uploadato/submitted nel file system visibile
function update_file($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){

	$siteurl=$_GLOBALS['siteurl'];
	$appname =$_GET['appname'];
	$filename=$_GET['filename'];
	$updatedir=$_GET['updatedir'];

 	copy ("$updatedir/$filename",$dpath.$filename);
	unlink("$updatedir/$filename");

	if (file_exists ("$updatedir/$filename.description")){
	    copy ("$updatedir/$filename.description",$dpath.$filename.".description");
	    unlink("$updatedir/$filename.description");
	}
	if (file_exists ("$updatedir/$filename.version.description")){
	    copy ("$updatedir/$filename.version.description",$dpath.$filename.".version.description");
	    unlink("$updatedir/$filename.version.description");
	}
	if (file_exists ("$updatedir/$filename.updateby.description")){
	    copy ("$updatedir/$filename.updateby.description",$dpath.$filename.".updateby.description");
	    unlink("$updatedir/$filename.updateby.description");
	}

	if (file_exists ("$updatedir/$filename.count")){
	    copy ("$updatedir/$filename.count",$dpath.$filename.".count");
	    unlink("$updatedir/$filename.count");
	}

	// i file preview
	if (file_exists("$updatedir/$filename".".preview.description.png")){
	    copy("$updatedir/$filename".".preview.description.png",$dpath.$filename.".preview.description.png");
	    unlink("$updatedir/$filename".".preview.description.png");
	}

	if (file_exists("$updatedir/$filename".".preview.description.gif")){
	    copy("$updatedir/$filename".".preview.description.gif",$dpath.$filename.".preview.description.gif");
	    unlink("$updatedir/$filename".".preview.description.gif");
	}

	if (file_exists("$updatedir/$filename".".preview.description.jpg")){
	    copy("$updatedir/$filename".".preview.description.jpg",$dpath.$filename.".preview.description.jpg");
	    unlink("$updatedir/$filename".".preview.description.jpg");
	}
	//------------------
	touch_path($dpath.$filename);

	echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._FILE_ACCEPTED."!</font><br/>";
	echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";
	}
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

// chiede il link proposto
function submit_link($dpath){

    $myforum=$_COOKIE['myforum'];
    $siteurl=$_GLOBALS['siteurl'];
    $appname =$_GET['appname'];
	if(user_getuser()!=""){
    echo "<br><table border='0' class='file' width='100%' style='padding:10px'>
    <form name='addfile' enctype='multipart/form-data' action='".$siteurl."index.php?appname=$appname&dpath=$dpath&action=exec_submit_link' method='post'>
    <tr>
    <td width='20%' class='black'>"._NOME_LINK."</td><td> <input name='name' type='text' size='30%'></td>
    </tr>
    <tr>
    <td width='20%' class='black'>"._INVIA_LINK."</td><td> <input name='link' type='text' size='30%'></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._DESC_LINK."</td><td> <textarea class='textarea' name='desc'></textarea></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._VERSION."</td><td> <input type='text' name='vers' size='30%' /></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._PREVIEW."</td><td> <input type='file' name='preview' size='35%' /></td>
    </tr>
    <tr>
    <td></td>
    <td>
	<input type='submit' value='"._SUBMIT_LINK."'>
	<input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
    </td>
    </tr>
    </form>
	</table>";
	}
    else echo "<br><div align='center'><font class='black_bold'>"._FERRACC."</font></div>";
}
//__________________________________________________________________________________________________________________________________

// esegue il caricamento del link proposto
function exec_submit_link($dpath){
    global $updatefiles;
    if(user_getuser()!=""){
	$myforum=$_COOKIE['myforum'];
	$appname =$_GET['appname'];
	$siteurl=$_GLOBALS['siteurl'];

	$name=$_POST['name'];
	$link=$_POST['link'];
	$desc=stripslashes($_POST['desc']);
	$vers=$_POST['vers'];


	$uploaddir =$siteurl."$updatefiles";

	if(user_getuser()!=""){

	    $hf=fopen("$uploaddir/".$name.".lnk","w");
    	    fwrite($hf,"$link");
	    fclose($hf);

	    if (move_uploaded_file($_FILES['preview']['tmp_name'], "$uploaddir/".$name.".lnk.preview.description.".substr($_FILES['preview']['name'],-3))) {
		chmod("$uploaddir/".$name.".lnk.preview.description.".substr($_FILES['preview']['name'],-3),0775);
	    }


	 //	Info
	    print "<table><tr><td><div align='left'>";
	    print "<br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._FILE_VALIDO."</font>";
	    print "<br>";
		print "<font class='red'>"._UPLOAD_DIRECTORY." </font>\"none_uploadfiles\"<br />";
	    print "<font class='red'>"._NOME_LINK." </font>".$name."<br />";
	    print "<font class='red'>"._FILE_REMOTO."</font>: ".$link."<br />";
	    print "<font class='red'>"._DESCRIPTION." </font>$desc <br/>";
	    print "<font class='red'>"._VERSION." </font>$vers <br />";
	    print "<font class='red'>"._UPDATEBY."</font> <a href='forum/index.php?op=profile&amp;user=$myforum'>$myforum</a><br />";
	    print "<font class='red'>"._PREVIEW." </font>".$_FILES['preview']['name']."<br />";
	    print "<br>";

	    if (file_exists("$uploaddir/".$name.".lnk.description") && $desc==""){
		$desc=join(file("$uploaddir/".$name.".lnk.description"));
		$desc=substr($desc,0,strrpos($desc,_UPDATEBY));
	    }

	    $hf=fopen("$uploaddir/".$name.".lnk.description","w");
	    fwrite($hf,"$desc");
	    fclose($hf);




    	    $hf=fopen("$uploaddir/".$name.".lnk.version.description","w");
	    fwrite($hf,"$vers");
	    fclose($hf);

	    $hf=fopen("$uploaddir/".$name.".lnk.updateby.description","w");
	    fwrite($hf,"$myforum");
	    fclose($hf);


	    echo "<font class='red_bold'>"._GREETING_UPDATE."</font><br/>";
	    echo "</div></td></tr></table>";

	    echo "<div align='left'><img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'><font class='black'>[Main]</font></a>&nbsp;&nbsp;";
	    echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";
	}
	else
	    echo _ERRORE_DI_AUTENTICAZIONE;
    }
    else echo "<br><div align='center'><font class='black_bold'>"._FERRACC."</font></div>";
}
//__________________________________________________________________________________________________________________________________

// chiede il nome del link
function add_link($dpath){

    $myforum=$_COOKIE['myforum'];
    $appname =$_GET['appname'];
    $siteurl=$_GLOBALS['siteurl'];

 // Admin form link user
    echo "<br><table border='0' class='file' width='100%' style='padding:10px'>
    <form  name='addfile' enctype='multipart/form-data' action='".$siteurl."index.php?appname=$appname&dpath=$dpath&action=exec_add_link' method='post'>
    <tr>
    <td  width='20%' class='black'>"._NOME_LINK."</td><td> <input name='name' type='text' size='30%'></td>
    </tr>
    <tr>
    <td width='20%' class='black'>"._INVIA_LINK."</td><td> <input name='link' type='text' size='30%'></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._DESC_LINK."</td><td> <textarea class='textarea' name='desc'></textarea></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._VERSION."</td><td> <input type='text' name='vers' size='30%' /></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._PREVIEW."</td><td> <input type='file' name='preview' size='35%' /></td>
    </tr>
    <tr>
    <td></td>
    <td>
	<input type='submit' value='"._ADD_LINK."'>
	<input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
    </td>
    </tr>
	</form>
    </table>";

}
//__________________________________________________________________________________________________________________________________

// esegue il caricamento del link
function exec_add_link($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =$_GET['appname'];
	$siteurl=$_GLOBALS['siteurl'];

	$name=$_POST['name'];
	$link=$_POST['link'];
	$desc=stripslashes($_POST['desc']);
	$vers=$_POST['vers'];

	$myforum=$_COOKIE['myforum'];
	$uploaddir = $dpath;

	if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	    $hf=fopen("$uploaddir/".$name.".lnk","w");
	    fwrite($hf,"$link");
	    fclose($hf);

	    if (move_uploaded_file($_FILES['preview']['tmp_name'], "$uploaddir/".$name.".lnk.preview.description.".substr($_FILES['preview']['name'],-3))) {
		chmod("$uploaddir/".$name.".lnk.preview.description.".substr($_FILES['preview']['name'],-3),0775);
	    }


	 // Info
	    print "<table><tr><td><div align='left'>";
	    print "<br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._FILE_VALIDO."</font>";
		print "<br>";
		print "<font class='red'>"._UPLOAD_DIRECTORY." </font>$uploaddir<br>";
	    print "<font class='red'>"._NOME_LINK." </font>".$name."<br />";
	    print "<font class='red'>"._FILE_REMOTO."</font>: ".$link."<br />";
	    print "<font class='red'>"._DESCRIPTION." </font>$desc <br/>";
		print "<font class='red'>"._VERSION." </font>$vers <br/>";
	    print "<font class='red'>"._UPDATEBY."</font> <a href='forum/index.php?op=profile&amp;user=$myforum'>$myforum</a><br/>";
	    print "<font class='red'>"._PREVIEW." </font>".$_FILES['preview']['name']."<br/>";
	    print "</br>";


	    if (file_exists("$dpath".$name.".description") && $desc==""){
		$desc=join(file("$dpath".$name.".description"));
	    }
	    $hf=fopen("$dpath".$name.".lnk.description","w");
	    fwrite($hf,"$desc");
	    fclose($hf);

	    $hf=fopen("$dpath".$name.".lnk.version.description","w");
	    fwrite($hf,"$vers");
	    fclose($hf);

	    $hf=fopen("$dpath".$name.".lnk.updateby.description","w");
	    fwrite($hf,"$myforum");
	    fclose($hf);
	    touch_path($dpath.$filename);

	    echo "</div></td></tr></table>";
	}
	else
	    echo _ERRORE_DI_AUTENTICAZIONE;

	echo "<div align='left'><img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'><font class='black'>[Main]</font></a>&nbsp;&nbsp;";
	echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";
    }
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

// chiede il file proposto
function submit_file($dpath){
    global $maxFileSize;

    $myforum=$_COOKIE['myforum'];
    $siteurl=$_GLOBALS['siteurl'];
    $appname =$_GET['appname'];

	if(user_getuser()!=""){
//  Form file user
	echo "<br><table border='0' class='file' width='100%' style='padding:10px'>
    <form name='addfile' enctype='multipart/form-data' action='".$siteurl."index.php?appname=$appname&dpath=$dpath&action=exec_submit_file' method='post'>
    <tr>
    <td width='20%' class='black'>"._INVIA_FILE."</td>
    <td>
	<input type='hidden' name='max_file_size' value='$maxFileSize' />
	<input name='file' type='file' size='30%'>
    </td>
    </tr>
    <tr>
    <td valign=top class='black'>"._DESC_FILE."</td><td> <textarea class='textarea' name='desc'></textarea></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._VERSION."</td><td> <input type='text' name='vers' size='30%' /></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._PREVIEW."</td><td> <input type='file' name='preview' size='35%' /></td>
    </tr>
    <tr>
    <td></td>
    <td>
	<input type='submit' value='"._SUBMIT_FILE."'>
	<input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
    </td>
    </tr>
    </form>
	</table>";
	}
    else echo "<br><div align='center'><font class='black_bold'>"._FERRACC."</font></div>";
}
//__________________________________________________________________________________________________________________________________

// esegue il caricamento del file proposto
function exec_submit_file($dpath){
    global $updatefiles;
    if(user_getuser()!=""){
	$myforum=$_COOKIE['myforum'];
	$appname =$_GET['appname'];
	$siteurl=$_GLOBALS['siteurl'];
	$desc=stripslashes($_POST['desc']);
	$vers=$_POST['vers'];

	$uploaddir =$siteurl."$updatefiles";

	if(user_getuser()!=""){
	    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir ."/". $_FILES['file']['name'])) {
		if (strtolower(substr($_FILES['file']['name'],-4))==".php")
		    unlink($uploaddir ."/".$_FILES['file']['name']);
		else{
		    chmod( $uploaddir ."/". $_FILES['file']['name'],0775);

		if (move_uploaded_file($_FILES['preview']['tmp_name'], $uploaddir."/".$_FILES['file']['name'].".preview.description.".substr($_FILES['preview']['name'],-3))) {
		    chmod($uploaddir."/".$_FILES['file']['name'].".preview.description.".substr($_FILES['preview']['name'],-3),0775);
		}


		 // Info
		    print "<table><tr><td><div align='left'>";
		    print "<br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._FILE_VALIDO."</font>";
		    print "<br>";
			print "<font class='red'>"._UPLOAD_DIRECTORY." </font>\"none_uploadfiles\"<br />";
		    print "<font class='red'>"._NOME_FILE." </font>".$_FILES['file']['name']."<br />";
		    print "<font class='red'>"._TIPO_FILE." </font>".$_FILES['file']['type']."<br />";
		    print "<font class='red'>"._SIZE_FILE." </font>".$_FILES['file']['size']."<br />";
		    print "<font class='red'>"._DESCRIPTION." </font>$desc <br/>";
			print "<font class='red'>"._VERSION." </font>$vers <br/>";
		    print "<font class='red'>"._UPDATEBY."</font> <a href='forum/index.php?op=profile&amp;user=$myforum'>$myforum</a><br/>";
		    print "<font class='red'>"._PREVIEW." </font>".$_FILES['preview']['name']."<br/>";
		    print "<br>";


		    if (file_exists("$uploaddir/".$_FILES['file']['name'].".description") && $desc==""){
			$desc=join(file("$uploaddir/".$_FILES['file']['name'].".description"));
			$desc=substr($desc,0,strrpos($desc,_UPDATEBY));
		    }

		    $hf=fopen("$uploaddir/".$_FILES['file']['name'].".description","w");
		    fwrite($hf,"$desc");
		    fclose($hf);

		    $hf=fopen("$uploaddir/".$_FILES['file']['name'].".version.description","w");
		    fwrite($hf,"$vers");
		    fclose($hf);

		    $hf=fopen("$uploaddir/".$_FILES['file']['name'].".updateby.description","w");
		    fwrite($hf,"$myforum");
		    fclose($hf);

		    echo "<font class='red_bold'>"._GREETING_UPDATE."</font><br/>";
		    echo "</div></td></tr></table>";
		}
	    } else {
		print "<table border='0'><tr><td>";
		print "<img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='red_bold'>"._FILE_NON_VALIDO."</font>";
		print "<br><pre>";
		print_r($_FILES);
		print "</pre>";
        echo "</td></tr></table>";
	    }

	echo "<div align='left'><img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'><font class='black'>[Main]</font></a>&nbsp;&nbsp;";
    echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";
	}
	else
	    echo _ERRORE_DI_AUTENTICAZIONE;
    }
    else echo "<br><div align='center'><font class='black_bold'>"._FERRACC."</font></div>";
}
//__________________________________________________________________________________________________________________________________

// chiede il nome del file
function add_file($dpath){
    global $maxFileSize;
    $myforum=$_COOKIE['myforum'];
    $appname =$_GET['appname'];
    $siteurl=$_GLOBALS['siteurl'];

 // Admin form link
    echo "<br>
	<table border='0' class='file' width='100%' style='padding:10px'>
    <form name='addfile' enctype='multipart/form-data' action='".$siteurl."index.php?appname=$appname&dpath=$dpath&action=exec_add_file' method='post'>
    <tr>
    <td width='20%' class='black'>"._INVIA_FILE."</td>
    <td>
	<input type='hidden' name='max_file_size' value='$maxFileSize' />
	<input  name='file' type='file' size='30%'>
    </td>
    </tr>
    <tr>
    <td valign=top class='black'>"._DESC_FILE."</td><td> <textarea class='textarea' name='desc'></textarea></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._VERSION."</td><td> <input type='text' name='vers' size='30%' /></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._PREVIEW."</td><td> <input type='file' name='preview' size='35%' /></td>
    </tr>
    <tr>
    <td></td>
    <td>
	<input type='submit' value='"._ADD_FILE."'>
	<input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
    </td>
    </tr>
	</form>
    </table>";

}
//__________________________________________________________________________________________________________________________________

// esegue il caricamento del file
function exec_add_file($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =$_GET['appname'];
	$siteurl=$_GLOBALS['siteurl'];
	$desc=stripslashes($_POST['desc']);
	$vers=$_POST['vers'];

	$myforum=$_COOKIE['myforum'];

	$uploaddir = $dpath;
	if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . $_FILES['file']['name'])) {
		chmod($uploaddir . $_FILES['file']['name'],0775);

		if (move_uploaded_file($_FILES['preview']['tmp_name'], $uploaddir .$_FILES['file']['name'].".preview.description.".substr($_FILES['preview']['name'],-3))) {
		    chmod($uploaddir .$_FILES['file']['name'].".preview.description.".substr($_FILES['preview']['name'],-3),0775);
		}

	 // Info
		print "<table><tr><td><div align='left'>";
		print "<br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._FILE_VALIDO."</font>";
		print "<br>";
		print "<font class='red'>"._UPLOAD_DIRECTORY." </font>$uploaddir <br />";
		print "<font class='red'>"._NOME_FILE." </font>".$_FILES['file']['name']."<br />";
		print "<font class='red'>"._TIPO_FILE." </font>".$_FILES['file']['type']."<br />";
		print "<font class='red'>"._SIZE_FILE." </font>".$_FILES['file']['size']."<br />";
		print "<font class='red'>"._DESCRIPTION." </font>$desc <br/>";
		print "<font class='red'>"._VERSION." </font>$vers <br/>";
		print "<font class='red'>"._UPDATEBY."</font> <a href='forum/index.php?op=profile&amp;user=$myforum'>$myforum</a><br/>";
		print "ciao<br>";
		print "<font class='red'>"._PREVIEW." </font>".$_FILES['preview']['name']."<br/>";
		print "<br>";

		if (file_exists("$uploaddir/".$_FILES['file']['name'].".description") && $desc==""){
		    $desc=join(file("$uploaddir/".$_FILES['file']['name'].".description"));
		}





		$hf=fopen("$dpath".$_FILES['file']['name'].".description","w");
		fwrite($hf,"$desc");
		fclose($hf);

		$hf=fopen("$dpath".$_FILES['file']['name'].".version.description","w");
		fwrite($hf,"$vers");
		fclose($hf);

		$hf=fopen("$dpath".$_FILES['file']['name'].".updateby.description","w");
		fwrite($hf,"$myforum");
		fclose($hf);
		touch_path($dpath.$filename);

		echo "</div></td></tr></table>";
	    } else {

		print "<table border='0'><tr><td>";
		print "<img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='red_bold'>"._FILE_NON_VALIDO."</font>";
		print "<br><pre>";
		print_r($_FILES);
		print "</pre>";
		echo "</td></tr></table>";
	    }
	}
	else
	    echo _ERRORE_DI_AUTENTICAZIONE;

	echo "<div align='left'><img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'><font class='black'>[Main]</font></a>&nbsp;&nbsp;";
    echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";
	}
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

// chiede il nuovo nome del file
function rename_file($dpath){
    $appname =$_GET['appname'];
    $filename=$_GET['filename'];
    $siteurl=$_GLOBALS['siteurl'];

    $desc=readdesc("$dpath$filename.description");
    $vers=readdesc("$dpath$filename.version.description");
    $updateby=readdesc("$dpath$filename.updateby.description");


 // Admin form link

    echo "<br>";

    echo "<table border='0' class='file'  width='100%' style='padding:10px'>
    <form name='renamefile' action='index.php?appname=$appname&dpath=$dpath&filename=$filename&action=exec_rename_file' method='POST' enctype='multipart/form-data'>
    <tr>
    <td width='20%' class='black'>"._NUOVO_NOME_FILE."</td><td><input 'type=text name='namefile' value='$filename' size='30%'></td>
    </tr>";
    if (strtolower(substr($filename,-4))=='.lnk'){
	echo"    <tr>
		    <td width='20%' class='black'>"._NUOVO_FILE_LINK."</td><td><input 'type=text name='namelink' value='".join(file($dpath.$filename))."' size='30%'></td>
		</tr>";
    }

    echo"<tr>
    <td valign=top class='black'>"._DESC_FILE."</td><td> <textarea  class='textarea' name='desc'>$desc</textarea></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._VERSION."</td><td> <input type='text' name='vers' size='30%' value='$vers'/></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._UPDATEBY."</td><td> <input type='text' name='updateby' size='30%' value='$updateby'/></td>
    </tr>
    <tr>
    <td valign=top class='black'>"._NEWFILE."</td>
	<td>
	    <input type='hidden' name='max_file_size' value='$maxFileSize' /><input  name='file' type='file' size='35%'>
	</td>
    </tr>
    <tr>
    <td valign=top class='black'>"._PREVIEW."</td><td> <input type='file' name='preview' size='35%' />&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' name='deletepreview'/> <font class='black'>"._DELETEPREVIEW."</font></td>

    </tr>

    <tr>
    <td></td><td><input type='submit' value='"._MODIFICA_FILE."'>
    <input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\"></td>
    </tr>
	</form>
    </table>";
}
//__________________________________________________________________________________________________________________________________

// esegue la rinomina del file
function exec_rename_file($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =$_GET['appname'];
	$filename=$_GET['filename'];
	$siteurl=$_GLOBALS['siteurl'];
	$namefile=$_POST['namefile'];
	$desc=stripslashes($_POST['desc']);
	$vers=$_POST['vers'];
	$updateby=$_POST['updateby'];
	if (strtolower(substr($filename,-4))=='.lnk')
		$namelink=$_POST['namelink'];
	$deletepreview= $_POST['deletepreview'];


	if (file_exists($dpath.$filename))
	    rename($dpath.$filename,$dpath.$namefile);
	if (file_exists($dpath.$filename.".count"))
	    rename($dpath.$filename.".count",$dpath.$namefile.".count");
	if (file_exists($dpath.$filename.".description"))
	    rename($dpath.$filename.".description",$dpath.$namefile.".description");
	if (file_exists($dpath.$filename.".version.description"))
	    rename($dpath.$filename.".version.description",$dpath.$namefile.".version.description");
	if (file_exists($dpath.$filename.".updateby.description"))
	    rename($dpath.$filename.".updateby.description",$dpath.$namefile.".updateby.description");

	if (file_exists($dpath.$filename.".preview.description.png"))
	    rename($dpath.$filename.".preview.description.png",$dpath.$namefile.".preview.description.png");
	if (file_exists($uploaddir.$filename.".preview.description.gif"))
	    rename($dpath.$filename.".preview.description.gif",$dpath.$namefile.".preview.description.gif");
	if (file_exists($dpath.$filename.".preview.description.jpg"))
	    rename($dpath.$filename.".preview.description.jpg",$dpath.$namefile.".preview.description.jpg");


	if (@join(@file($dpath.$namefile.".version.description"))!=$vers){
	    touch($dpath.$namefile);
	    touch_path($dpath.$namefile);
	}


	writedesc($dpath.$namefile.".description",$desc);
	writedesc($dpath.$namefile.".version.description",$vers);
	writedesc($dpath.$namefile.".updateby.description",$updateby);

	if ($filename !=$namefile)
	    touch_path($dpath.$filename);

	if (strtolower(substr($namefile,-4))=='.lnk' && trim(@join(@file($dpath.$namefile)))!=trim($namelink) ){
	    $hf=fopen($dpath.$namefile,"w");
    	    fwrite($hf,"$namelink");
	    fclose($hf);
	    touch_path($dpath.$filename);
	}

	$uploaddir = $dpath;
	if ($_FILES['file']['tmp_name']!=""){
	    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir .$namefile) ) {
		chmod($uploaddir . $namefile,0775);
	    }else {
		echo" errore <br/>";
		print_r($_FILES);
	    }
	}

	if ($_FILES['preview']['tmp_name']!="" || $deletepreview !=""){
	    if (file_exists($uploaddir.$namefile.".preview.description.png"))
		unlink($uploaddir.$namefile.".preview.description.png");
	    if (file_exists($uploaddir.$namefile.".preview.description.gif"))
		unlink($uploaddir.$namefile.".preview.description.gif");
	    if (file_exists($uploaddir.$namefile.".preview.description.jpg"))
		unlink($uploaddir.$namefile.".preview.description.jpg");
	}
	if ($_FILES['preview']['tmp_name']!="" ){
	    if (move_uploaded_file($_FILES['preview']['tmp_name'], $uploaddir.$namefile.".preview.description.".substr($_FILES['preview']['name'],-3))) {
		chmod($uploaddir.$namefile.".preview.description.".substr($_FILES['preview']['name'],-3),0775);
	    }
	}

	echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._FILE_MODIFIED."!</font><br/>";
	echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";
	}
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

// esegue lo spostamento del file
function cut_file($dpath){
    global $updatefiles;
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =$_GET['appname'];
	$filename=$_GET['filename'];
	$siteurl=$_GLOBALS['siteurl'];
	$updatedir="$updatefiles/";


	copy($dpath.$filename,$updatedir.$filename);
	unlink($dpath.$filename);
	if (file_exists($dpath.$filename.".description")){
	    copy($dpath.$filename.".description",$updatedir.$filename.".description");
	    unlink($dpath.$filename.".description");
	}
	if (file_exists($dpath.$filename.".version.description")){
	    copy($dpath.$filename.".version.description",$updatedir.$filename.".version.description");
	    unlink($dpath.$filename.".version.description");
	}
	if (file_exists($dpath.$filename.".updateby.description")){
	    copy($dpath.$filename.".updateby.description",$updatedir.$filename.".updateby.description");
	    unlink($dpath.$filename.".updateby.description");
	}
	if (file_exists($dpath.$filename.".count")){
	    copy($dpath.$filename.".count",$updatedir.$filename.".count");
	    unlink($dpath.$filename.".count");
	}

	// i file preview
	if (file_exists($dpath.$filename.".preview.description.png")){
	    copy($dpath.$filename.".preview.description.png",$updatedir.$filename.".preview.description.png");
	    unlink($dpath.$filename.".preview.description.png");
	}

	if (file_exists($dpath.$filename.".preview.description.gif")){
	    copy($dpath.$filename.".preview.description.gif",$updatedir.$filename.".preview.description.gif");
	    unlink($dpath.$filename.".preview.description.gif");
	}

	if (file_exists($dpath.$filename.".preview.description.jpg")){
	    copy($dpath.$filename.".preview.description.jpg",$updatedir.$filename.".preview.description.jpg");
	    unlink($dpath.$filename.".preview.description.jpg");
	}
	//------------------

	echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._FILE_SPOSTATO."!</font><br/>";
	echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";
    }
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

// cancella il file
function delete_file($dpath){
    $appname =$_GET['appname'];
    $filename=$_GET['filename'];
    $siteurl=$_GLOBALS['siteurl'];

    echo "<br>";
    echo "<form name='deletedir' action='index.php?appname=$appname&dpath=$dpath&filename=$filename&action=exec_delete_file' method='POST'>
	<div class='black_bold'>"._IN_FILE."$dpath$filename</div><br><br>
	<input type='submit' value='"._ELIMINA."'>
	<input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
	</form>";
}
//__________________________________________________________________________________________________________________________________

// esegue la cancellazione del file
function exec_delete_file($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =$_GET['appname'];
	$filename=$_GET['filename'];
	$siteurl=$_GLOBALS['siteurl'];

	if (file_exists($dpath.$filename.".description"))
	    unlink($dpath.$filename.".description");
	if (file_exists($dpath.$filename.".version.description"))
	    unlink($dpath.$filename.".version.description");
	if (file_exists($dpath.$filename.".updateby.description"))
	    unlink($dpath.$filename.".updateby.description");
	if (file_exists($dpath.$filename.".count"))
	    unlink($dpath.$filename.".count");

	if (file_exists($dpath.$filename.".preview.description.png"))
	    unlink($dpath.$filename.".preview.description.png");
	if (file_exists($dpath.$filename.".preview.description.gif"))
	    unlink($dpath.$filename.".preview.description.gif");
	if (file_exists($dpath.$filename.".preview.description.jpg"))
	    unlink($dpath.$filename.".preview.description.jpg");


	if (unlink($dpath.$filename)!=true){
	    echo "<br><font class='black_bold'>"._IN_FILE."$dpath$filename</font><br><br>
		<input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
	    ";
	}
	else{
	    echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class=black_bold>"._FILE_DELETED."!</font><br/>";
	    echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";
	}
    }
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

// cancella il file sottomesso
function delete_submitfile($dpath){
    $appname =$_GET['appname'];
    $updatedir=$_GET['updatedir'];
    $filename=$_GET['filename'];
    $siteurl=$_GLOBALS['siteurl'];


    echo "<br>";
    echo "<form name=deletedir>
	<div class='black_bold'>"._IN_FILE." $updatedir/$filename</div><br><br>
	<input type='button' value='"._ELIMINA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath&updatedir=$updatedir&filename=$filename&action=exec_delete_submitfile';\">
	<input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
	</form>";
}
//__________________________________________________________________________________________________________________________________

// esegue la cancellazione del file sottomesso
function exec_delete_submitfile($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =$_GET['appname'];
	$updatedir=$_GET['updatedir'];
	$filename=$_GET['filename'];
	$siteurl=$_GLOBALS['siteurl'];


	if (file_exists("$updatedir/$filename".".description"))
	    unlink("$updatedir/$filename".".description");
	if (file_exists("$updatedir/$filename".".version.description"))
	    unlink("$updatedir/$filename".".version.description");
	if (file_exists("$updatedir/$filename"."..updateby.description"))
	    unlink("$updatedir/$filename"."..updateby.description");
	if (file_exists("$updatedir/$filename".".count"))
	    unlink("$updatedir/$filename".".count");

	if (file_exists("$updatedir/$filename".".preview.description.png"))
	    unlink("$updatedir/$filename".".preview.description.png");
	if (file_exists("$updatedir/$filename".".preview.description.gif"))
	    unlink("$updatedir/$filename".".preview.description.gif");
	if (file_exists("$updatedir/$filename".".preview.description.jpg"))
	    unlink("$updatedir/$filename".".preview.description.jpg");

	if (unlink("$updatedir/$filename")!=true){
		echo "<br><font class='black_bold'>"._IN_FILE."$updatedir/$filename</font><br><br>
	    <input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
	    ";

	}
	else{
	    echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._FILE_DELETED."!</font><br/>";
	    echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";
	}
    }
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

// chiede il nome della directory
function add_dir($dpath){
    global $lang;
    $appname =$_GET['appname'];
    $siteurl=$_GLOBALS['siteurl'];

 // Admin form link

    echo "<br>";
    echo "<table border='0' class='file' width='100%' style='padding:10px'>
    <form name='adddir' action='index.php?appname=$appname&dpath=$dpath&action=exec_add_dir' method='POST' enctype='multipart/form-data'>
    <tr>";
    echo "<td width='20%' class='black'>"._NOME_DIR."</td><td> <input type='text' name='namedir' value='";
	switch($lang) {
	case "it":
	echo "Nuova cartella";
	break;
	case "en":
	echo "New folder";
	break;
	default:
	echo "Nuova cartella";
	break;
	}
	echo "' size='30%'></td>";
    echo "</tr>
    <tr>
    <td valign=top class='black'>"._DESC_DIR."</td><td> <textarea class='textarea' name='descdir'></textarea></td>
    </tr>
    <tr>
    <td></td>
    <td><input type='submit' value='"._ADD_DIR."' >
    <input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\"></td>
    </tr>
	</form>
    </table>";
}
//__________________________________________________________________________________________________________________________________

// esegue la creazione della directory
function exec_add_dir($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$siteurl=$_GLOBALS['siteurl'];
	$appname =$_GET['appname'];
	$namedir=$_POST['namedir'];
	$descdir=stripslashes($_POST['descdir']);


	mkdir($dpath.$namedir,0775);

	$hf=fopen("$dpath/$namedir.description","w");
	fwrite($hf,"$descdir");
	fclose($hf);
	touch_path($dpath.$filename);

	echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._DIR_ADDED."!</font><br/>";
    echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";
	}
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

// chiede il nuovo nome della directory
function rename_dir($dpath){
    $appname =$_GET['appname'];
    $filename=$_GET['filename'];
    $siteurl=$_GLOBALS['siteurl'];
    if (file_exists("$dpath$filename.description"))
	$desc=readdesc("$dpath$filename.description");

 // Admin form link
    echo "<br>";
    echo "<table border='0' class='file'  width='100%' style='padding:10px'>
    <form name='renamedir' action='index.php?appname=$appname&dpath=$dpath&filename=$filename&action=exec_rename_dir' method='POST' enctype='multipart/form-data'>
    <tr>
    <td width='24%' class='black'>"._NUOVO_NOME_DIR."</td><td><input type='text' name='namedir' value='$filename' size='30%'></td>
    </tr>
    <tr>
    <td valign='top' class='black'>"._DESC_DIR."</td><td> <textarea class='textarea' name='desc'>$desc</textarea></td>
    </tr>
    <tr><td></td>
    <td><input type='submit' value='"._RINOMINA_DIR."' \">
    <input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\"></td>
    </tr>
	</form>
    </table>";
}
//__________________________________________________________________________________________________________________________________

// esegue la rinomina della directory
function exec_rename_dir($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$siteurl=$_GLOBALS['siteurl'];
	$appname =$_GET['appname'];
	$filename=$_GET['filename'];
	$namedir=$_POST['namedir'];
	$desc=stripslashes($_POST['desc']);

 	rename($dpath.$filename,$dpath.$namedir);
	if (file_exists($dpath.$filename.".description"))
	    rename($dpath.$filename.".description",$dpath.$namedir.".description");

	if (@join(@file($dpath."/".$namedir.".description"))!=$desc){
	    writedesc($dpath."/".$namedir.".description",$desc);
	    touch_path($dpath.$filename);
	}

	echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._DIR_RENAMED."!</font><br>";
	echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";
    }
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

// taglia la directory
function cut_dir($dpath){
    global $updatefiles;
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname=appname();
	$filename=$_GET['filename'];
	$siteurl=$_GLOBALS['siteurl'];

	$source=$dpath.$filename;
	$dest="$updatefiles/$filename";
	copytree($source,$dest);
	copy($source.".description",$dest.".description");
	deltree ($source);
	unlink($source.".description");
    }
    echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._DIR_CUTTED."!</font><br>";
    echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";

}
//__________________________________________________________________________________________________________________________________

// incolla la directory
function update_dir($dpath){
    global $updatefiles;
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =appname();
	$filename=$_GET['filename'];
	$siteurl=$_GLOBALS['siteurl'];

	$source="$updatefiles/$filename";
	$dest=$dpath.$filename;
	copytree($source,$dest);
	copy($source.".description",$dest.".description");
	deltree ($source);
	if (file_exists($source.".description"))
	    unlink($source.".description");
    }
    echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._DIR_UPDATED."!</font><br>";
    echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";

}
//__________________________________________________________________________________________________________________________________

// elimina la directory tagliata
function delete_update_dir($dpath){
    global $updatefiles;
    $appname =appname();
    $filename=$_GET['filename'];
    $siteurl=$_GLOBALS['siteurl'];

    echo "<br>";
    echo "<form name=deletedir>
	<div class='black_bold'>"._IN."$updatefiles$filename</div><br><br>
	<input type='button' value='"._CANCELLA_DIR."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath&filename=$filename&action=exec_delete_update_dir';\">
	<input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
	</form>";
}
//__________________________________________________________________________________________________________________________________

// esegue l'eliminazione della directory tagliata
function exec_delete_update_dir($dpath){
    global $updatefiles;
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =appname();
	$filename=$_GET['filename'];
	$siteurl=$_GLOBALS['siteurl'];

	$source="$updatefiles/$filename";
	deltree($source);
	if (file_exists($source.".description"))
	    unlink($source.".description");
    }
    echo "<br><br><img src='aplications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._FILE_DELETED."!</font><br/>";
    echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?apname=$appname&dpath=$dpath\">";

}
//__________________________________________________________________________________________________________________________________

// cancella la directory
function delete_dir($dpath){
    $appname =$_GET['appname'];
    $filename=$_GET['filename'];
    $siteurl=$_GLOBALS['siteurl'];

    echo "<br>";
    echo "<form name=deletedir>
	<div class='black_bold'>"._IN."$dpath$filename</div><br><br>
	<input type='button' value='"._CANCELLA_DIR."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath&filename=$filename&action=exec_delete_dir';\">
	<input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
	</form>";
}
//__________________________________________________________________________________________________________________________________

// esegue la cancellazione della directory
function exec_delete_dir($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =$_GET['appname'];
	$filename=$_GET['filename'];
	$siteurl=$_GLOBALS['siteurl'];

	if (@rmdir($dpath.$filename)!=true){
	    echo "<br><font class='red_bold'>"._DIR_IN."$dpath$filename "._NOT_EMPTY." </font><br><br>
	    <input type='button' value='"._CANCELLA_TREE."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath&filename=$filename&action=exec_deltree_dir';\">
	    <input type='button' value='"._ANNULLA."' onclick=\"javascript:window.location.href='".$siteurl."index.php?appname=$appname&dpath=$dpath';\">
	    ";
	}
	else{
	    unlink($dpath.$filename.".description");
	    echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._DIR_DELETED."!</font><br/>";
	    echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";
	}
    }
    else
	die(_NONPUOI);
}
//__________________________________________________________________________________________________________________________________

//esegue la cancellazione del'uintero albero di directory
function exec_deltree_dir($dpath){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	$appname =$_GET['appname'];
	$filename=$_GET['filename'];
	$siteurl=$_GLOBALS['siteurl'];


	deltree($dpath.$filename);
	unlink($dpath.$filename.".description");
	echo "<br><br><img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>"._DIR_DELETED."!</font><br/>";
	echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".$siteurl."index.php?appname=$appname&dpath=$dpath\">";
    }
    else
	die(_NONPUOI);
}

//__________________________________________________________________________________________________________________________________

// esegue il download richiesto e incrementa il contatore dei download per il file
function download($dpath){
    $appname =$_GET['appname'];
    $filename=$_GET['filename'];
    $siteurl=$_GLOBALS['siteurl'];

    $f=$dpath.$filename.".count";
	if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
		if(file_exists("$f")==false){
		$hf=fopen("$f","w");
		fwrite($hf,"1");
		fclose($hf);
		}else{
		$hf=fopen("$f","r");
		$i=fread($hf,1024);
		$i++;
		fclose($hf);
		$hf=fopen("$f","w");
		fwrite($hf,$i);
		fclose($hf);
		}
	}
    if (substr($dpath.$filename,-4)==".lnk"){
	//header("location:".join(file("$siteurl$dpath$filename")));
	echo"If don't start download please click  <a href='".join(file("$siteurl$dpath$filename"))."'>$filename</a><br/>";
	echo "<meta http-equiv=\"Refresh\" content=\"0; URL=".join(file("$siteurl$dpath$filename"))." \" >";
	echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";

    }
    else{
	//header("location: $siteurl$dpath$filename");
	echo" If don't start download please click <a href='$siteurl$dpath$filename'>$filename</a><br/>";
	echo "<meta http-equiv=\"Refresh\" content=\"0; URL=$siteurl$dpath$filename \" >";
	echo "<a href='".$siteurl."index.php?appname=$appname&dpath=$dpath'><font class='black'>["._CONTINUA."]</font></a> <img src='applications/$appname/none_images/icon2.gif'align='absmiddle'></div>";

    }
}
//__________________________________________________________________________________________________________________________________

// stampa il path con i relativi link
function dirtitle($dpath){
    $appname =$_GET['appname'];
    $a=0;
    $dirlist="";
    $out="";
    $p="";

    for($i=0;$i<strlen($dpath)-1;$i++){
	if($dpath[$i]=="/"){
	    $a++;
	    $p=$p."$dirlist/";
	    if($dirlist!="datas" &&$dirlist!="applications")
		$out=$out."<a href='index.php?appname=".$appname."&dpath=$p'>$dirlist/</a> ";
	    $dirlist="";
	}
	else{
	    $dirlist=$dirlist.$dpath[$i];
	}
    }
    $p=$p."$dirlist";
    $out=$out."$dirlist";
	echo "&nbsp;<img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>Location</font> &#187;&nbsp;$out";
}
//__________________________________________________________________________________________________________________________________

// visualizza il contenuto di dpath
function dirlist($dpath){

    global $updatefiles;
    $appname =$_GET['appname'];
    $siteurl=$_GLOBALS['siteurl'];
    $updatedir ="$updatefiles";

    $extfs=opendir("applications/$appname/none_images");
    while (false !== ($extimg= readdir($extfs))){
	if (substr($extimg,-4)==".png")
	    $ext[substr(substr($extimg,0,-4),-3)]=$extimg;
    }
    closedir($extfs);



// Directory
    echo "<br>";
    if (!file_exists($dpath)){
	echo _PATH_ERROR;
    }
    else{
	foreach(listdir($dpath) as $filename){
	    if ($filename !="." && $filename !=".."){
		if (is_dir($dpath.$filename)!=false && substr_count($dpath.$filename,"/none_")==0 ){

		    $i= ($i+1)& 1;
		    $zip_dir="<a href='".$siteurl."index.php?appname=".$appname."&zip_op=zipdir&dpath=$dpath&filename=$filename'> <font class='black_bold'>Download directory</font></a>";
		    $actionlink="index.php?appname=".$appname."&dpath=$dpath&filename=$filename";
		    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
			$cut_dir="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=cut_dir'>"._CUT."</a>]";
			$rename_dir="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=rename_dir'>"._REN."</a>]";
			$delete_dir="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=delete_dir'>"._DEL."</a>]";
		    }
		    echo "<table border='0' width='100%'><tr><td valign='top'>";
		    echo "<div class='directory'>";
		    echo "<table width='100%' border='0' cellspacing='0'><tr>";
		    echo "<td valign='top' align='right' width='3%'>";
		    echo "<a href='index.php?appname=".$appname."&dpath=$dpath$filename/'><img src='applications/$appname/none_images/dir.png' border='0' align='top'></a></td>
		    <td align='justify' valign='top'><a href='index.php?appname=".$appname."&dpath=$dpath$filename/'><font class='black_bold'>$filename</font></a><br>";
	     // Admin mini panel
		    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
			echo "<span class='admin_panel'>$cut_dir $rename_dir $delete_dir</span>";
			echo "<br>";
		    }
		    $dpath1="$dpath/$filename";


		    if(file_exists("$dpath1.description")){
			if(filesize("$dpath1.description")>1){
			    echo "<font class='grey_bold'> "._DESCRIPTION."</font> ";
			    readfile("$dpath1.description");
			}
		    }
		    echo "</td><td valign='top' align='right' width='25'>";
		    if ( filemtime("$dpath/$filename")> mktime (0,0,0,date("m"),date("d")-5,  date("Y"))){
			echo"<img src='applications/$appname/none_images/new.gif'>";
		    }
		    echo "</tr>";
		    echo "<tr><td align='right'><a href='".$siteurl."index.php?appname=".$appname."&zip_op=zipdir&dpath=$dpath&filename=$filename'><img src='applications/$appname/none_images/mini_down.gif' align='bottom' border='0'></a></td>";
		    echo "<td>$zip_dir </td>";
		    echo "</tr></table></div>";
		    echo "</td></tr></table>";
		}
	    }
	}

    // Files
	foreach(listdir($dpath) as $filename){
	    if ($filename !="." && $filename !=".." && substr_count($filename,".description")==0 && substr($filename,-6)!=".count"){
		if (is_dir("$dpath/$filename")==false){

		    echo "<a name='".str_replace("/","-",$dpath.$filename)."'>";
		    $f=$dpath.$filename.".count";
		    if (file_exists($f)){
			$hf=fopen("$f","r");
			$count=fread($hf,1024);
			fclose($hf);
		    }
		    else{
			$count=0;
		    }
		    $i= (($i+1)& 1)+2;
		    $actionlink="index.php?appname=".$appname."&dpath=$dpath&filename=$filename";
		    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
			$rename_file="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=rename_file'>"._REN."</a>]";
			$delete_file="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=delete_file'>"._DEL."</a>]";
			$cut_file="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=cut_file'>"._CUT."</a>]";
		    }

		    if ($ext[substr($filename,-3)]!="")
			$picture="<img src='applications/$appname/none_images/".$ext[substr($filename,-3)]."' border='0'>";
		    else
			$picture="<img src='applications/$appname/none_images/unknown.png' border='0'>";
		    if (substr($filename,-2)=="gz")
			$picture="<img src='applications/$appname/none_images/tgz.png' border='0'>";

		    $preview="";
		    if (strtolower(substr($filename,-3))=="png" || strtolower(substr($filename,-3))=="gif"|| strtolower(substr($filename,-3))=="jpg")
			$preview="$dpath/$filename";
		    if (file_exists("$dpath/$filename.preview.description.png"))
			$preview="$dpath/$filename.preview.description.png";
		    if (file_exists("$dpath/$filename.preview.description.gif"))
			$preview="$dpath/$filename.preview.description.gif";
		    if (file_exists("$dpath/$filename.preview.description.jpg"))
			$preview="$dpath/$filename.preview.description.jpg";

		    $ico="<img src='applications/$appname/none_images/icon8.gif' border='0'>";
		    echo "<table width='100%' border='0'>";
		    echo "<tr><td valign='top'>";
		    echo "<div class='file'>";
		    echo "<table width='100%' border='0' cellspacing='0'><tr>";
		    echo "<td  valign='top' align='center' width='6%'>";
		    echo "$picture";
		    echo "</td>";
		    echo "<td align='justify' valign='top'>";
		    //echo "<font class='grey_bold'>"._NOME_FILE." </font>";
		    echo "<a href='$actionlink&action=download'><font class='black_big'>$filename</font></a>";
	       // Admin mini panel
		    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
			echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='admin_panel'>$cut_file $delete_file $rename_file</span>";
		    }
		    if ( filemtime("$dpath/$filename")> mktime (0,0,0,date("m"),date("d")-5,  date("Y"))){
			echo"&nbsp;&nbsp;<img src='applications/$appname/none_images/new.gif'>";
		    }
		    echo"<br>$ico <font class='grey_bold'>"._RILASCIO." </font> ".date("j.m.y",filemtime("$dpath/$filename"))."";

		    if(strtolower(substr($filename,-4))<>".lnk"){
			echo "<br>$ico <font class='grey_bold'>"._SIZE_FILE." </font>".round(filesize("$dpath/$filename")/1000)."Kb ";
		    }
		    else
			echo "<br>$ico <font class='grey_bold'>"._FILE_REMOTO." </font>";

		    echo"<br>$ico <font class='grey_bold'>Downloads: </font> $count  ";
		    $dpath1="$dpath/$filename";

		    if(file_exists("$dpath1.updateby.description")){
			if(filesize("$dpath1.updateby.description")>1){
			    echo "<br>$ico <font class='grey_bold'>"._UPDATEBY." </font>";
			    $updateby=trim(join(file("$dpath1.updateby.description")));
			    echo"<a href='forum/index.php?op=profile&amp;user=$updateby'>$updateby</a>";
			}
		    }
		    if(file_exists("$dpath1.version.description")){
			if(filesize("$dpath1.version.description")>1){
			    echo "<br>$ico <font class='grey_bold'>"._VERSION." </font>";

			    readfile("$dpath1.version.description");
			}
		    }

		    if(file_exists("$dpath1.description")){
			if(filesize("$dpath1.description")>1){
			    echo "<br>$ico <font class='grey_bold'> "._DESCRIPTION."</font> ";
			    readfile("$dpath1.description");
			    echo "<br>";
			}
		    }


		    echo"</td>";
		    echo "<td align='right' valign='top' width='25' style='padding:3'>";
		    if ($preview!="")echo "<a href='$preview' ><img src='$preview' border='0' width='128'/></a>";
		    echo "</td></tr><tr><td align='right' valign='top' width='25'></td>";

	     // Download link
		    echo "<td><img src='applications/$appname/none_images/mini_down.gif' align='bottom' border='0'> <a href='$actionlink&action=download'><font class='black_bold'> Download!</font></a>";
		    echo "</td>";
		    echo "</tr></table></div>";
		    echo "</td></tr></table>";
		}
		echo "</a>";
	    }
	}
    }

 // Clipboard

    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	echo "<br>";

	echo "<table width='100%'><tr><td class='clipboard_title'>&nbsp;<img src='applications/$appname/none_images/icon2.gif' border='0'> <font class='black_bold'>Clipboard:</font>&nbsp <img src='applications/$appname/none_images/mini_down.gif' align='absmiddle' border='0'> ["._UPDATE_FILES."] ";
	echo "</td></tr></table>";


	foreach(listdir("$updatedir/") as $filename){
	    if ($filename[0]!='.'){
		if (is_dir("$updatedir/$filename")==true){
		    $actionlink="index.php?appname=".$appname."&dpath=$dpath&filename=$filename";
		    $delete_dir="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=delete_update_dir'>"._DELETE_DIR."</a>]";
		    $update_dir="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=update_dir'>"._PUT_DOWN."</a>]";
		    $picture="<img src='applications/$appname/none_images/dir.png' border='0'>";

		    echo "<table width='100%' border='0'>";
		    echo "<tr>";
		    echo "<td valign='top'>";
		    echo "<div class='clipboard'>";
		    echo "<table border='0' width='100%'><tr>";
		    echo "<td valign='top' align='right' width='3%'>";
		    echo "$picture";
		    echo "</td>";
		    echo "<td align='justify' valign=top style='padding-right:20;'>";

		    echo "<font class='red_bold'>".$filename."</font>";
		    echo "<br>";

		    // Admin mini panel
		    echo "<span class='admin_panel'>$delete_dir $update_dir</span>";

		    echo "</td></tr></table>\n";
		    echo "</td></tr></table>\n";
		}
	    }
	}

	foreach(listdir("$updatedir/") as $filename){
	    if (substr_count($filename,".description")==0 && substr($filename,-6)!=".count"){
		if (is_dir("$updatedir/$filename")==false){
		    $count=0;
		    $actionlink="index.php?appname=".$appname."&dpath=$dpath&updatedir=$updatedir&filename=$filename";
		    $update_file="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=update_file'>"._PUT_DOWN."</a>]";
		    $delete_file="<img src='applications/$appname/none_images/icon2.gif' border='0'>[<a href='$actionlink&action=delete_submitfile'>"._DEL."</a>]";

		    if ($ext[substr($filename,-3)]!="")
			$picture="<img src='applications/$appname/none_images/".$ext[substr($filename,-3)]."' border='0'>";
		    else
			$picture="<img src='applications/$appname/none_images/unknown.png' border='0'>";
		    if (substr($filename,-2)=="gz")
			$picture="<img src='applications/$appname/none_images/tgz.png' border='0'>";
		    if (substr($filename,-2)=="gz")
			$picture="<img src='applications/$appname/none_images/tgz.png' border='0'>";


		    $preview="";
		    if (strtolower(substr($filename,-3))=="png" || strtolower(substr($filename,-3))=="gif"|| strtolower(substr($filename,-3))=="jpg")
			$preview="$updatedir/$filename";
		    if (file_exists("$updatedir/$filename.preview.description.png"))
			$preview="$updatedir/$filename.preview.description.png";
		    if (file_exists("$updatedir/$filename.preview.description.gif"))
			$preview="$updatedir/$filename.preview.description.gif";
		    if (file_exists("$updatedir/$filename.preview.description.jpg"))
			$preview="$updatedir/$filename.preview.description.jpg";


		    echo "<table width='100%' border='0'>";
		    echo "<tr>";
		    echo "<td valign='top'>";
		    echo "<div class='clipboard'>";
		    echo "<table border='0' width='100%'><tr>";
		    echo "<td valign='top' align='right' width='3%'>";
		    echo "$picture";
		    echo "</td>";
		    echo "<td align='justify' valign=top style='padding-right:20;'>";

		    if (substr($filename,-3)=="lnk")
			echo "<a href='".join(file("$updatedir/$filename"))."'><font class='red_bold'>$filename</font></a>";
		    else
			echo "<a href='$updatedir/$filename'><font class='red_bold'>$filename</font></a>";
		    echo "<font class='black'> - "._DATE_UPLOAD." </font> ".date("j.m.y",filemtime("$updatedir/$filename"))."";

		    if(strtolower(substr($filename,-4))<>".lnk"){
			echo "<font class='black'> - "._SIZE_FILE." </font>".round(filesize("$updatedir/$filename")/1000)."Kb ";
		    }
		    else
			echo "<font class='black'> - "._FILE_REMOTO." </font>";

		    $dpath1="$updatedir/$filename";
		    echo " - <font class='black'>"._UPDATEBY." </font>";
		    if(file_exists("$dpath1.updateby.description")){
			if(filesize("$dpath1.updateby.description")>=0){
			    $updateby=trim(join(file("$dpath1.updateby.description")));
			    echo "<a href='forum/index.php?op=profile&amp;user=$updateby'>$updateby</a>";
			}
		    }
		    if(file_exists("$dpath1.version.description")){
			if(filesize("$dpath1.version.description")>1){
			    echo "<font class='black'> - "._VERSION." </font>";
			    readfile("$dpath1.version.description");
			}
		    }
		    echo "<br>";

		 // Admin mini panel
			echo "<span class='admin_panel'>$delete_file $update_file</span>";

		    echo "<br>";
		    if(file_exists("$dpath1.description")){
			if(filesize("$dpath1.description")>1){
			    echo "<font class='grey_bold'>"._DESCRIPTION." </font>";
			    readfile("$dpath1.description");
			}
		    }

		    echo "<td>";
			if ($preview!="")echo "<td align='right'><a href='$preview' ><img src='$preview' border='0' width='128'/></a></td>";
		    echo "</td></tr></table></div>";
			echo "</td></tr></table>";
	    }
	}
    }

    }
}
//__________________________________________________________________________________________________________________________________

//protezione da path "strani"
if($dpath[0]=='.')$dpath="";
if($dpath[0]=='/')$dpath="";
if (substr($dpath,-2)=="//")$dpath=substr($dpath,0,-1);
if (substr_count($dpath,"..")!=0)$dpath="";
if (substr($dpath,0,strlen("datas/applications/".sec_title($appname)."/"))!="datas/applications/".sec_title($appname)."/")$dpath="";
if ($dpath=="")$dpath="datas/applications/".sec_title($appname)."/";



// Menu big up
 // Menu left
    $constants=get_defined_constants();
    $menutitle=$constants["_".strtoupper($action)];
	$iconadmin="&nbsp;&nbsp;[<img src='applications/$appname/none_images/admin.png' align='absmiddle' alt='-'> Admin]";

	echo "<table border='0' width='100%'><tr><td valign='top'>";
	echo "<div id='change'><div class='left_panel'>";
	echo "<div class='menu_title'>";
	if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin())
	    echo "&nbsp;<img src='applications/$appname/none_images/icon2.gif' border='0'>";
	else
	    if (user_getuser()!="")
		echo "&nbsp;<img src='applications/$appname/none_images/icon.gif' border='0'>";
	    else
		echo "&nbsp;<img src='applications/$appname/none_images/icon5.gif' border='0'>";

   switch($action){
	case "add_link":
	    echo $iconadmin;
	    break;
	case"exec_add_link":
	    echo $iconadmin;
	    break;
	case "update_file":
	    echo $iconadmin;
	    break;
	case "delete_submitfile":
	    echo $iconadmin;
	    break;
	case "exec_delete_submitfile":
	    echo $iconadmin;
	    break;
	case "add_file":
	    echo $iconadmin;
	    break;
	case "exec_add_file":
	    echo $iconadmin;
	    break;
	case "rename_file":
	    echo $iconadmin;
	    break;
	case "exec_rename_file":
	    echo $iconadmin;
	    break;
	case "cut_file":
	    echo $iconadmin;
	    break;
	case "delete_file":
	    echo $iconadmin;
	    break;
	case "exec_delete_file":
	    echo $iconadmin;
	    break;
	case "add_dir":
	    echo $iconadmin;
	    break;
	case "exec_add_dir":
	    echo $iconadmin;
	    break;
	case "rename_dir":
	    echo $iconadmin;
	    break;
	case "exec_rename_dir":
	    echo $iconadmin;
	    break;
	case "cut_dir":
	    echo $iconadmin;
	    break;
	case "update_dir":
	    echo $iconadmin;
	    break;
	case "delete_update_dir":
	    echo $iconadmin;
	    break;
	case "exec_delete_update_dir":
	    echo $iconadmin;
	    break;
	case "delete_dir":
	    echo $iconadmin;
	    break;
	case "exec_delete_dir":
	    echo $iconadmin;
	    break;
	case "exec_deltree_dir":
	    echo $iconadmin;
	    break;
    }

	echo "&nbsp;$menutitle";
	if ($menutitle=="") echo "Files - FlatNuke file manager";
	echo "</div>";
	echo "&nbsp;<img src='applications/$appname/none_images/icon4.gif' border='0'> <a href='index.php?appname=$appname'>[Main]</a>";
	echo "<br>";
	echo "&nbsp;<img src='applications/$appname/none_images/icon3.gif' border='0'> &nbsp;<a href='javascript:window.history.back();'>[Back]</a>";
	echo "<br>";
	$search="&nbsp;<img src='applications/$appname/none_images/icon2.gif' border='0'> &nbsp;<a href='index.php?appname=".$appname."&action=search'>["._FINDFILES."]</a>";
    echo "$search";
	echo "<br>";
	dirtitle($dpath);
	echo "</div></div>";

    echo "</td>";

 // Admin panel
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	echo "<td valign='top'>";
	echo "<div id='change'><div class='panel'>";
	echo "<div class='menu_title'>";
	echo "&nbsp;<img src='applications/$appname/none_images/icon2.gif' border='0'> Admin panel";
	echo "</div>";
	$actionlink="index.php?appname=".$appname."&dpath=$dpath";
	$add_dir="&nbsp;<img src='applications/$appname/none_images/mini_up.gif' align='absmiddle' border='0'> <a href='$actionlink&action=add_dir'>["._ADD_DIR_ADMIN."]</a>";
	$add_file="&nbsp;<img src='applications/$appname/none_images/mini_up.gif' align='absmiddle' border='0'> <a href='$actionlink&action=add_file'>["._ADD_FILE_ADMIN."]</a>";
	$add_link="&nbsp;<img src='applications/$appname/none_images/mini_up.gif' align='absmiddle' border='0'> <a href='$actionlink&action=add_link'>["._ADD_LINK_ADMIN."]</a>";
	echo "$add_file";
	echo "<br>";
	echo "$add_link";
	echo "<br>";
	echo "$add_dir ";
	echo "</div></div>";
    }
    echo "</td>";

 // User panel
	echo "<td valign='top'>";
	echo "<div id='change'><div class='panel'>";
	echo "<div class='menu_title'>";

	if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin())
	    echo "&nbsp;<img src='applications/$appname/none_images/icon2.gif' border='0'>&nbsp;User panel";
	else if (user_getuser()!="")
	echo "<img src='applications/$appname/none_images/icon.gif' border='0'>&nbsp;"._FN_REG."";
	else
	echo "<img src='applications/$appname/none_images/icon5.gif' border='0'>&nbsp;"._FN_UNREG."";
	echo "</div>";
	$actionlink="index.php?appname=".$appname."&dpath=$dpath";
	if(user_getuser()!="" ){
	$submit_file="<img src='applications/$appname/none_images/mini_up.gif' align='absmiddle' border='0'> <a href='$actionlink&action=submit_file'>["._UPFILE."]</a>";
	echo "$submit_file";
	echo "<br>";
	$submit_link="<img src='applications/$appname/none_images/mini_up.gif' align='absmiddle' border='0'> <a href='$actionlink&action=submit_link'>["._UPLINK."]</a>";
	echo "$submit_link";
	echo "<br>";
	}

	$help="&nbsp;<img src='applications/$appname/none_images/icon2.gif' border='0'> <a href='index.php?appname=".$appname."&action=help'>[Help]</a>";
	echo "$help";
	echo "<br>";
	echo "&nbsp;<img src='applications/$appname/none_images/icon2.gif' border='0'> <a href='index.php?appname=".$appname."&dpath=$dpath&action=top_new'>["._TOPNEW."]</a>";
	echo "<br>";
	echo "&nbsp;<img src='applications/$appname/none_images/icon2.gif' border='0'> <a href='index.php?appname=".$appname."&dpath=$dpath&action=top_download'>["._TOPDOWNLOAD."]</a>";
	echo "</div></div>";
	echo "</td></tr>";
	echo "</table>";

// l'albero degli eventi
    switch($action){
	case "download":
	    download($dpath);
	    break;
	case "help":
	    help($dpath);
	    break;
	case "top_new":
	    top_new($dpath);
	    break;
	case "top_download":
	    top_download($dpath);
	    break;
	case "search":
	    search($dpath);
	    break;
	case "exec_search":
	    exec_search($dpath);
	    break;
	case "submit_link":
	    submit_link($dpath);
	    break;
	case "exec_submit_link":
	    exec_submit_link($dpath);
	    break;
	case "add_link":
	    add_link($dpath);
	    break;
	case "exec_add_link":
	    exec_add_link($dpath);
	    break;
	case "submit_file":
	    submit_file($dpath);
	    break;
	case "exec_submit_file":
	    exec_submit_file($dpath);
	    break;
	case "update_file":
	    update_file($dpath);
	    break;
	case "delete_submitfile":
	    delete_submitfile($dpath);
	    break;
	case "exec_delete_submitfile":
	    exec_delete_submitfile($dpath);
	    break;
	case "add_file":
	    add_file($dpath);
	    break;
	case "exec_add_file":
	    exec_add_file($dpath);
	    break;
	case "rename_file":
	    rename_file($dpath);
	    break;
	case "exec_rename_file":
	    exec_rename_file($dpath);
	    break;
	case "cut_file":
		cut_file($dpath);
		break;
	case "delete_file":
	    delete_file($dpath);
	    break;
	case "exec_delete_file":
	    exec_delete_file($dpath);
	    break;
	case "add_dir":
	    add_dir($dpath);
	    break;
	case "exec_add_dir":
	    exec_add_dir($dpath);
	    break;
	case "rename_dir":
	    rename_dir($dpath);
	    break;
	case "exec_rename_dir":
	    exec_rename_dir($dpath);
	    break;
	case "cut_dir":
	    cut_dir($dpath);
	    break;
	case "update_dir":
	    update_dir($dpath);
	    break;
	case "delete_update_dir":
	    delete_update_dir($dpath);
	    break;
	case "exec_delete_update_dir":
	    exec_delete_update_dir($dpath);
	    break;
	case "delete_dir":
	    delete_dir($dpath);
	    break;
	case "exec_delete_dir":
	    exec_delete_dir($dpath);
	    break;
	case "exec_deltree_dir":
	    exec_deltree_dir($dpath);
	    break;
	default:
	    dirlist($dpath);
	    break;

	case "download":
	    download($dpath);
	    break;
	case "help":
	    help($dpath);
	    break;
	case "top_new":
	    top_new($dpath);
	    break;
	case "top_download":
	    top_download($dpath);
	    break;
	case "search":
	    search($dpath);
	    break;
	case "exec_search":
	    exec_search($dpath);
	    break;
	case "submit_link":
	    submit_link($dpath);
	    break;
	case "exec_submit_link":
	    exec_submit_link($dpath);
	    break;
	case "add_link":
	    add_link($dpath);
	    break;
	case "exec_add_link":
	    exec_add_link($dpath);
	    break;
	case "submit_file":
	    submit_file($dpath);
	    break;
	case "exec_submit_file":
	    exec_submit_file($dpath);
	    break;
	case "update_file":
	    update_file($dpath);
	    break;
	case "delete_submitfile":
	    delete_submitfile($dpath);
	    break;
	case "exec_delete_submitfile":
	    exec_delete_submitfile($dpath);
	    break;
	case "exec_cut_file":
	    exec_cut_file($dpath);
	    break;
	case "add_file":
	    add_file($dpath);
	    break;
	case "exec_add_file":
	    exec_add_file($dpath);
	    break;
	case "rename_file":
	    rename_file($dpath);
	    break;
	case "exec_rename_file":
	    exec_rename_file($dpath);
	    break;
	case "delete_file":
	    delete_file($dpath);
	    break;
	case "exec_delete_file":
	    exec_delete_file($dpath);
	    break;
	case "add_dir":
	    add_dir($dpath);
	    break;
	case "exec_add_dir":
	    exec_add_dir($dpath);
	    break;
	case "rename_dir":
	    rename_dir($dpath);
	    break;
	case "exec_rename_dir":
	    exec_rename_dir($dpath);
	    break;
	case "delete_dir":
	    delete_dir($dpath);
	    break;
	case "exec_delete_dir":
	    exec_delete_dir($dpath);
	    break;
	case "cut_file":
		cut_file($dpath);
		break;
	default:
	    dirlist($dpath);
	    break;
    }

    structure_closeBlock();
?>
